<template>
	<div class="wrapper">
		<image :src="botInfo.iconUrl" mode="aspectFill" class="bor50 icon" v-if="botInfo.iconUrl"></image>
		<image src="@/static/t-logo.png" mode="aspectFill" class="bor50 icon" v-else></image>
		<div class="f40 fbold mt35 mb25 tCenter">{{botInfo.name}}</div>
		<div class="f30 c000 tCenter description">{{botInfo.description}}</div>
		<div class="nav flex-start bfff" @click="clear">
			<image src="/static/clear.png" mode="widthFix" class="nav-icon mr26"></image>
			<div class="f30">清除上下文</div>
		</div>
	</div>
</template>

<script setup>
	import {
		getCurrentInstance,
		ref
	} from 'vue'
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	import useLoginStore from '@/store/modules/index'
	import {
		storeToRefs
	} from 'pinia'
	import {
		info
	} from '../../apis/botinfo.js'
	const loginStore = useLoginStore()
	const {
		proxy
	} = getCurrentInstance()

	const {
		uinfo
	} = storeToRefs(loginStore)

	function clear() {
		proxy.sToast('已清除上下文')
		proxy.back(1, 1000)

	}

	// 接收上个页面参数并自动发送
	onLoad((option) => {
		if (option.botId) {
			botId.value = option.botId
			getBotInfo()
		} else {

		}
	});
	const botId = ref('')
	const botInfo = ref({})
	async function getBotInfo() {
		const result = await info({
			botId: botId.value
		})
		if (result && result.success) {
			botInfo.value = result.data
		}
	}
</script>
<style lang='scss'>
	.wrapper {
		background-color: #f7f7f7;
		min-height: 100vh;
		overflow: hidden;

		.nav-icon {
			width: 60rpx;
			height: 60rpx;
		}

		.description {
			width: 590rpx;
			margin: 0 auto 100rpx;
		}

		.nav {
			box-shadow: 3rpx 0rpx 8rpx 0rpx rgba(198, 198, 198, .4);
			height: 100rpx;
			margin: 28rpx 30rpx 0;
			padding: 0 30rpx;
			border-radius: 20rpx;
		}

		.icon {
			width: 300rpx;
			height: 300rpx;
			margin: 30rpx auto 50rpx;
			display: block;
		}
	}
</style>